//
//  YDFVisitorTableViewController.swift
//  weibo20
//
//  Created by mac on 16/1/21.
//  Copyright © 2016年 tingyuyisheng. All rights reserved.
//

import UIKit

class YDFVisitorTableViewController: UITableViewController {

	private var userLogin = false

/// 访客视图属性
	var visitorView : YDFVisitorView?

	override func loadView() {
/// 判断是否登陆成功
		userLogin ? super.loadView() : setupVisitor()
	}

	private func setupVisitor() {

		visitorView = YDFVisitorView()
		visitorView?.delegate = self
		view = visitorView
		view.backgroundColor = UIColor(white: 237 / 255.0, alpha: 1)

		navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "VisitorViewDidRegister")
		navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "VisitorViewDidLogin")
	}
}

extension YDFVisitorTableViewController: YDFVisitorViewDelegate {

    /// 登陆
	func VisitorViewDidLogin() {
        let VC = YDFOAuthViewController()
        let nav = UINavigationController(rootViewController: VC)
        presentViewController(nav, animated: true, completion: nil)
	}

	func VisitorViewDidRegister() {
	}
}
